<?php

class StatisticsController extends AppController {

	var $name = 'Statistics';
	var $helpers = array('Html','Form','Ajax','Javascript','Runstatistic','Pondstatistic');
    var $layout = 'default';
    var $pageTitle = 'Mass Swap Helper';
    var $components = array('RequestHandler');

	function beforeRender() {
		$groupid = $this->Auth->user('group_id');
		$name = 'Statistics';
		IF($groupid != 1){
			$result1 = mysql_query("SELECT id FROM applications WHERE name = '$name'");
			$appid = mysql_fetch_object($result1)->id;
			$result2 = mysql_query("SELECT count(*) as count FROM groupshasrights WHERE group_id = '$groupid' AND application_id = '$appid'");
			$count = mysql_fetch_object($result2)->count;
			IF($count == 0){
				$this->Session->setFlash(__('Access Denied', true));
				$this->redirect(array('controller' => 'pages' ,'action' => 'error'));	
			}
		}
	}
    
	function runoverview(){
		$result = mysql_query("SELECT id FROM runs ORDER BY id ASC");
		$this->set(compact('result'));
	}
	
	
	function pondoverview(){
		
	}


    
}
?>
